import {Component, ViewChild} from '@angular/core';
import {NavController, ActionSheetController, ModalController, AlertController} from 'ionic-angular';
import {AddContentPage} from '../../components/add-content/add-content';
import {TimeLine} from "../../components/time-line/time-line";

/*
 Generated class for the Home page.

 See http://ionicframework.com/docs/v2/components/#navigation for more info on
 Ionic pages and navigation.
 */
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  @ViewChild(TimeLine)
  timeline: TimeLine;

  constructor(public navCtrl: NavController,
              public actionSheetCtrl: ActionSheetController,
              public modalCtrl: ModalController,
              public alertCtrl: AlertController,) {

  }

  ionViewDidLoad(): void {
    this.timeline.fetch();
  }

  presentAddActionSheet() {
    let actionSheet = this.actionSheetCtrl.create({
      title: 'Add',
      buttons: [
        {
          text: 'Add Content',
          handler: () => {
            let modal = this.modalCtrl.create(AddContentPage, {
              title: 'Add Content'
            });
            modal.present();
          }
        },
        {
          text: 'Add Message',
          handler: () => {
            let modal = this.modalCtrl.create(AddContentPage, {
              disablePicture: true,
              title: 'Add Message'
            });
            modal.present();
          }
        },
        // {
        //   text: 'Add Voice Notification',
        //   handler: () => {
        //     let date = new Date(new Date().getTime() + (5 * 1000));
        //     let alert = this.alertCtrl.create({
        //       title: 'New Friend!',
        //       subTitle: 'notify will fire when' + date,
        //       buttons: ['OK']
        //     });
        //     alert.present();
        //     LocalNotifications.schedule({
        //       id: 1,
        //       text: 'Delayed ILocalNotification',
        //       at: date
        //     });
        //
        //   }
        // },
        {
          text: 'Cancel',
          role: 'cancel'
        }
      ]
    });
    actionSheet.present();
  }

}
